Avoid equality comparisons with Double.NaN - these are likely to be logic errors.
